package com.business.appealtype.service;

import java.util.List;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.business.system.common.base.BaseService;
import com.business.system.common.support.Convert;
import com.business.appealtype.mapper.auto.AppealTypeMapper;
import com.business.appealtype.model.auto.AppealType;
import com.business.appealtype.model.auto.AppealTypeExample;
import com.business.system.model.custom.Tablepar;
import com.business.system.util.SnowflakeIdWorker;

/**
 * 诉求类型 AppealTypeService
 * @Title: AppealTypeService.java 
 * @Package com.business.appealtype.service 
 * @author lujingyuan_自动生成
 * @email 674326842@qq.com
 * @date 2020-11-18 13:48:11  
 **/
@Service
public class AppealTypeService implements BaseService<AppealType, AppealTypeExample>{
	@Autowired
	private AppealTypeMapper appealTypeMapper;
	
      	   	      	      	      	      	      	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<AppealType> list(Tablepar tablepar,String name){
	        AppealTypeExample testExample=new AppealTypeExample();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andNameLike("%"+name+"%");
	        }

	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<AppealType> list= appealTypeMapper.selectByExample(testExample);
	        PageInfo<AppealType> pageInfo = new PageInfo<AppealType>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=Convert.toListStrArray(ids);
			AppealTypeExample example=new AppealTypeExample();
			example.createCriteria().andIdIn(lista);
			return appealTypeMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public AppealType selectByPrimaryKey(String id) {
				
			return appealTypeMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(AppealType record) {
		return appealTypeMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(AppealType record) {
				
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
			
				
		return appealTypeMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(AppealType record, AppealTypeExample example) {
		
		return appealTypeMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(AppealType record, AppealTypeExample example) {
		
		return appealTypeMapper.updateByExample(record, example);
	}

	@Override
	public List<AppealType> selectByExample(AppealTypeExample example) {
		
		return appealTypeMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(AppealTypeExample example) {
		
		return appealTypeMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(AppealTypeExample example) {
		
		return appealTypeMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param appealType
	 * @return
	 */
	public int checkNameUnique(AppealType appealType){
		AppealTypeExample example=new AppealTypeExample();
		example.createCriteria().andNameEqualTo(appealType.getName());
		List<AppealType> list=appealTypeMapper.selectByExample(example);
		return list.size();
	}


}
